<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        for(var i = 0; i < 5; i++) {
            setTimeout(function(){
                console.log(new Date, i);
            },1000);

        }
        // 输出
// Sat Jan 28 2023 14:56:03 GMT+0800 (中国标准时间) 5
//  Sat Jan 28 2023 14:56:03 GMT+0800 (中国标准时间) 5
//  Sat Jan 28 2023 14:56:03 GMT+0800 (中国标准时间) 5
//  Sat Jan 28 2023 14:56:03 GMT+0800 (中国标准时间) 5
//  Sat Jan 28 2023 14:56:03 GMT+0800 (中国标准时间) 5
    </script>
</body>
</html>